<?php
// set file to read
$filename = "../g-config/konek.php";

$newdata = '<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_konek = "'.$_POST['hostname'].'";
$database_konek = "'.$_POST['database'].'";
$username_konek = "'.$_POST['username'].'";
$password_konek = "'.$_POST['password'].'";
$base_url = "'.$_POST['base_url'].'";

error_reporting(0);
$konek = mysql_pconnect($hostname_konek, $username_konek, $password_konek);
 
 if(!$konek)
{
?>
	
	 <script language="javascript">
  	<!--
     	    alert("Lakukan Installasi Koneksi Website")
			window.location = "install/";
			
   	--></script>
	<?php
}
?>';

if ($newdata != '' and $_POST['hostname']) {

// open file
$fw = fopen($filename, 'w') or die('Could not open file!');
// write to file
// added stripslashes to $newdata
$fb = fwrite($fw,stripslashes($newdata)) or die('Could not write
to file');
// close file
fclose($fw);
header('location: ../');
}

// open file
  $fh = fopen($filename, "r") or die("Could not open file!");
// read file contents
  $data = fread($fh, filesize($filename)) or die("Could not read file!");
// close file
  fclose($fh);
// print file contents

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Install Geriloji CMS</title>
<link href='../g-konten/fm/icon.png' rel='shortcut icon'/>

    <!-- Bootstrap -->
    <link href="../g-template/default/css/bootstrap.min.css" rel="stylesheet">
    <link href="../g-template/default/css/default.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="../g-template/default/css/default.css" />
    <link rel="stylesheet" type="text/css" href="../g-template/default/css/menu.css" />
	<link rel="stylesheet" type="text/css" href="../g-template/default/css/component.css" />
	<script src="../g-template/default/js/modernizr.custom.js"></script>
	<!-- Add jQuery library -->
	<script type="text/javascript" src="../g-template/default/fancy/lib/jquery-1.10.1.min.js"></script>


	<!-- Add fancyBox main JS and CSS files -->
	<script type="text/javascript" src="../g-template/default/fancy/source/jquery.fancybox.js?v=2.1.5"></script>
	<link rel="stylesheet" type="text/css" href="../g-template/default/fancy/source/jquery.fancybox.css?v=2.1.5" media="screen" />


	<!-- Add Thumbnail helper (this is optional) -->
	<link rel="stylesheet" type="text/css" href="../g-template/default/fancy/source/helpers/jquery.fancybox-thumbs.css?v=1.0.7" />
	<script type="text/javascript" src="../g-template/default/fancy/source/helpers/jquery.fancybox-thumbs.js?v=1.0.7"></script>

	<script type="text/javascript">
	var coy = jQuery.noConflict();
		coy(document).ready(function() {
			
			coy('.fancybox-thumbs').fancybox({
				prevEffect : 'none',
				nextEffect : 'none',

				closeBtn  : false,
				arrows    : true,
				nextClick : true,

				helpers : {
					thumbs : {
						width  : 50,
						height : 50
					}
				}
			});

			

		});
	</script>

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->


</head>
<body style="background:#FFF">
<div class="container">
<div align="center" style="margin:20px;">
<img src="../g-konten/fm/logo.png" class="img-rounded">
<h1>Configurasi Koneksi Database</h1></div>
<form action="" method="post" class="form-horizontal" role="form">
<div class="form-group">
    <label class="col-sm-2 control-label" >Host Name </label>
    <div class="col-sm-10">
    <input type="text" name="hostname" class="form-control col-lg-5" placeholder=" ... ">
    </div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label" >Database </label>
    <div class="col-sm-10">
    <input type="text" name="database" class="form-control col-lg-5" placeholder=" ... ">
    </div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label" >Username </label>
    <div class="col-sm-10">
    <input type="text" name="username" class="form-control col-lg-5" placeholder=" ... ">
    </div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label" >Password </label>
    <div class="col-sm-10">
    <input type="text" name="password" class="form-control col-lg-5" placeholder=" ... ">
    </div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label" >Base URL</label>
    <div class="col-sm-10">
    <input type="text" name="base_url" class="form-control col-lg-5" placeholder=" ... ">
    </div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type='submit' value='Submit' class="btn btn-default" >
</div>
</div>
</form>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
		<script src="../g-template/default/js/cbpHorizontalMenu.min.js"></script>
		<script>
			$(function() {
				cbpHorizontalMenu.init();
			});
		</script>
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="../g-template/default/js/bootstrap.min.js"></script>

</body>
</html>
